var app = getApp();
var util = require("../../utils/util.js");
var siteinfo = require('../../siteinfo.js');
Page({
    data: {
        isCheck: false,
        isSignUp: true,
        status: '',
        list:[],
    },

    onLoad: function (options) {
        wx.removeStorageSync('hcdatalist')
        // this.getList()
        this.handleGetBkTime()
        this.handleGetUserInfo()
    },

    onShow: function () {
        wx.removeStorageSync('hcdatalist')
    },
    handleGetBkTime:function () {
        let token = wx.getStorageSync('token');
        wx.request({
            url: siteinfo.siteroot3 + 'jzApi/informationBatch/selInformationBatchs',
            header: {
                'Authorization': token,
                'content-type': 'application/json'
            },
            method: 'GET',
            success: (res) => {
                console.log(res);
                if (res.data.code === 0 || res.data.code === '0') {
                    // _this.setData(res.data.data);
                    this.setData({
                        list: res.data.data.list
                    });
                } else {
                    app.showError(res.data.msg);
                    _this.setData({
                        isSignUp: false
                    });
                    return false;
                }
            }
        });
    },
    // 查询报名信息
    handleGetUserInfo: function () {
        let token = wx.getStorageSync('token');
        wx.request({
            url: siteinfo.siteroot3 + 'jzApi/informationImportUser/getUserInfo',
            header: {
                'Authorization': token,
                'content-type': 'application/json'
            },
            method: 'GET',
            data: {
            },
            success: (res) => {
                console.log(res);
                if (res.data.code == 0) {
                    this.setData({
                        status: res.data.data.checkStatus
                    })
                }
            }
        });
    },

    //获取证书考试信息
    getList: function () {
        var _this = this;
        var requestHead = {
            'content-type': 'application/json'
        }
        wx.request({
            url: siteinfo.siteroot3 + 'jzApi/certificates/selCertificateDetails',
            header: requestHead,
            data: {},
            success: function (res) {
                console.log(res);
                if (res.data.code === 0 || res.data.code === '0') {
                    // _this.setData(res.data.data);
                    _this.setData({
                        list: res.data.data.list
                    });
                    list
                } else {
                    app.showError(res.data.msg);
                    _this.setData({
                        isSignUp: false
                    });
                    return false;
                }
            }
        });
    },
    showModal1: function () {
        wx.navigateTo({
            url: '/pages/useRagreement/useRagreement'
        })
    },
    //判断是否已阅读
    radioChange: function (e) {
        var _this = this
        this.setData({
            isCheck: !_this.data.isCheck
        })
    },
    next: function (e) {
        wx.setStorageSync("certificateInfo", e.currentTarget.dataset.list);
            let token = wx.getStorageSync('token')
            if (!token) {
                app.doLogin()
                return false;
            }else{
                // var _this = this
                // if (false == _this.data.isCheck) {
                //     app.showError('请认真阅读，并勾选已阅读');
                //     return false;
                // }
                if (this.data.status == null || this.data.status=='') {
                    wx.navigateTo({
                        url: '/pages/signentry/signentry'
                    })

                } else {
                    wx.navigateTo({
                        url: '/pages/entryCompleted/entryCompleted'
                    })
            }

        }

        // 原页面
        // wx.navigateTo({
        //   url: '/pages/signInformation/signInformation?id=' + _this.data.id,
        // })
    },
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})